package com.tjetc._1staitc;


class Test1 {
    static int count = 9;

    public void count() {
        System.out.println("count=" + (count++));
    }
}

// 判断当前代码是否能通过编译 如果编译不过 进行修改 并回答最后的输出内容
class Person {
    private int id;
    private static int total = 0;
    public static int getTotalPerson() {
//        id++; // 静态方法不能调用成员属性
        return total;
    }
    public Person() {
        total++;
    }
}

// 判断当前代码是否能通过编译 如果编译不过 进行修改 并回答最后的输出内容
class Person1 {
    private int id; // 4
    private static int total = 0; // 3 4
    public static void setTotalPerson(int total){
//        this.total = total; //this 不能在静态方法中使用
        Person1.total = total;
    }
    public Person1() {
        total++;
        id = total;
    }
}


public class _4StaticExercise {
    public static void main(String[] args) {
        Person1.setTotalPerson(3);
        new Person1(); // total的值 4

    }

    public static void main2(String[] args) {
        System.out.println("Number of total is " +Person.getTotalPerson()); // 0
        Person p1 = new Person();
        System.out.println( "Number of total is "+ Person.getTotalPerson()); // 1
    }


    public static void main1(String[] args) {
        new Test1().count(); // 9
        new Test1().count(); // 10
        System.out.println(Test1.count);// 11
    }
}

